using Godot;

namespace ZerAx.Roguelike
{
    public partial class GuiSystem : Control
    {
        [Export]
        private Root root;
        [Export]
        private Control content;
        [Export]
        private Toaster toaster;

        private StringName rootFieldName = "root";

        public void LoadContent(PackedScene scene)
        {
            var c = scene.Instantiate<Control>();
            c.Set(rootFieldName, root);
            if (content.GetChildCount() > 0) 
            {
                for (int i = 0; i < content.GetChildCount(); i++)
                {
                    content.GetChild(i).QueueFree();
                }
            }
            content.AddChild(c);
        }

        public void MakeToast(string message, float life = 2.0f)
        {
            toaster.MakeToast(message, life);
        }
    }
}